Part Number Hot Search : 
N74F540N 12N035T 474HA 599101 SA12A 30011 RN1221 AM79C203
Product Description
Full Text Search
 

To Download AN2614 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  august 2007 rev 1 1/12 AN2614 application note serial numbering implementation introduction it is common practice to give appliances a unique serial or identification number. this serial number is located in the external memory of the device, for example in eeprom, but it can also be programmed with the mcu software, inside the mcu program memory array. in some cases, the serial number should remain secret and unreadable to external devices. in other cases, it should be readable from the mcu by a remote pc through any interface specified by the manufacturer (for example, sci). this application note provides technical deta ils on the software and tools associated with implementing a serial numbering technique. some hints have been taken from the on-line help of the stvp7 visual programming software tool. c language examples are provided which are ready to be added to the source code if compiled with a metrowerks c compiler (such as old hiware, panta or codewarrior). the examples provide may also be ported to other c compilers. the examples can be applied to any st7 micr ocontrollers which is equipped with non volatile memory. www.st.com
serial number encoding techniques AN2614 2/12 1 serial number encoding techniques a serial number can be composed of any number of letters and/or digits. a common serial number encoding technique is to encode the serial number as a string of ascii characters, as shown in ta bl e 1 . the numbers can also be combined in pairs, to form more concise 2- digit characters as shown in ta b l e 2 . other encoding techniques are possible. such ?encryption? can be used so that only authorized people can decode the serial number. table 1. serial numbering serial number 0 1 2 3 4 5 6 7 corresponding ascii codes (hexa) 30h 31h 32h 33h 34h 35h 36h 37h table 2. serial numbering in pairs serial number 0 1 2 3 4 5 6 7 corresponding numbers (hexa) 01h 23h 45h 67h
AN2614 embedding the serial number 3/12 2 embedding the serial number the serial number may need to be: 1. embedded in the mcu, or stored in external memory (such as eeprom) 2. read from the mcu by an external device (for example, through an sci interface) 3. protected against read-out 4. programmed at production level or updated just before shipment embedding the serial number inside the mcu software meets all the above requirements. this is especially true for the st7 microcontrollers, whose flash memory array can be programmed anytime with minimum hardware requirements (by means of icp or iap). before embedding the serial number, its format (size, encoding etc.) should be known . for exampe, a serial number encoded over a four-character identification string may look as follows: char serial_number[4]; 2.1 embedding the serial number inside the mcu software 2.1.1 fixed serial number this is the easiest way to implement the serial number, since it can either be programmed with the mcu software or programmed later. if a common serial number is assigned to all appliances of a production lot, the string can be part of the normal mcu software without any specific requirements, as shown below: #pragma into_rom // in case -cc option is not used const char serial_number[4] = ?0123?; // forget the trailing ?\0?
embedding the serial number AN2614 4/12 2.1.2 reserving space fo r unique serial numbers if a different number needs to be given to each mcu, then a specific area must be reserved inside the software memory array which can be programmed on a chip-by-chip basis. this is done inside the prm file. a section indi cating the size of the identification string should be created, and a placement name assigned to it. in the following example, 4 bytes are reserved at the beginning of the flash memory array: sections //... ser_num = read_only 0x1000 to 0x1003;/* serial number area */ user_rom = read_only 0x1004 to 0xffdf;/* flash area */ placement //... serial into ser_num; in the software, the identification string may then be allocated inside this dedicated memory space as follows: #pragma const_seg serial // map the next string into serial section const char serial_number[4]; #pragma const_seg default // restore normal string mapping once compiled and linked, the map file will show a segment called ?serial? which is four-bytes wide and contains the serial number as shown below: ****************************************************** segment-allocation section ------------------------------------------------------ segmentname size type from to name serial 4 r 1000 1003 ser_num 2.1.3 protection against read-out to avoid subsequent reads of the serial number, the entire st7 flash memory array can be protected against read-out by enabling the read-out protection bit located in the first option byte. protection is thus ensured as it can only be removed by erasing the entire flash memory array (see section 3: automatic serial number generation in the mcu on page 6 ). note: such read-out protection is device-dependent and is not a feature of all mcus.
AN2614 embedding the serial number 5/12 2.2 getting the serial number from an external device the serial number may be programmed in exte rnal memory, such as eeprom. in this way, the mcu software memory array and the eepr om data array can be programmed in a number of different ways: by each device using its own respective programming tool by the mcu receiving the serial number later (for example, through an sci interface) and then programming the eeprom accordingly the mcu must read the eeprom upon reset (if the serial number is to be processed by it) and must store the serial number in ram, as follows: char serial_number[4]; void main(void) { //... read_eeprom(serial_number, subaddress); // read string and store it into serial_number in this way, the serial number is not permanently stored in the mcu and all mcus in the production lot can be programmed with exactly the same contents.
automatic serial number generation in the mcu AN2614 6/12 3 automatic serial number generation in the mcu the stvp7 software tool provided with each epb or st7 stick is well suited for automatic serial number generation in the mcu. the step-by-step procedure described below is also available from the on-line help in the ?help/index? menu under stvp7. 3.1 creating a project the first step is to create a ?project? under stvp7. a project is a way of automatically configuring st vp7 each time it is run. a project exists in a file format that contains stvp7 commands. this allows the user to set up a programming environment and to define programming pr ocedures by opening the project file. such procedures may include the following actions: erase everything before programming (flash memory devices only) blank check before programming verify after programming enable read-out protection prompt for new programming cycle generate and write serial numbers to create a project: click on ?new? in the project menu. the ?create new project? dialog box opens. in the drive list, click the drive on which you want to create the new project file. in the box beneath the drive list, double-click the name of the folder in which you want to create the new project file. continue double-clicking subfolders until you open the subfolder in which you want to create the file. type the project file name in the file name box. click on ?save? (the project f ile name extension is .stp). the name of the project appears in the window title bar. the project is now created and contains the configuration settings (under the configuration menu) ?hardware?, ?port?, ?programming mode? and ?device?.
AN2614 automatic serial number generation in the mcu 7/12 3.2 project set-up under the ?project/edit? menu, five configuration windows (or tabs) need to be set up. 3.2.1 configuration window the programmer?s hardware and the mcu type are described in the configuration window. the configuration at the time the project was created can be modified here. 3.2.2 properties window the list of sequential actions to be performed for each chip are defined in the properties window. figure 1 shows the various programming options. figure 1. programming options the main options include: blank check before programming: the device is blank checked first verify after programming clear memory before loading a file: this cl ears (= fill with ffh) the existing memory values in the stvp7 session when loading a ne w file. if it is not checked each time a new file is loaded, only those memory values in the newly loaded file are overwritten. erase device memory before programming unlock protection before a programming cycle: if the read-out protection needs to be removed at the beginning of a cycle because the device was protected prior to exectuting the project, stvp7 must reprogram the device in a specific way
automatic serial number generation in the mcu AN2614 8/12 prompt for new programming cycle: if the same programming procedure needs to be repeated for several microcontrollers, a dialog box appears at the end of each programming cycle and asks if the same programming cycle is to be restarted. to program an mcu repeatedly, the following boxes should be ticked: verify after programming display a popup window when an error occurs prompt for new programming cycle (optional) the above assumes that the mcu is blank. if it has to be erased first, the following two boxes should also be checked: blank check before programming erase device memory before programming if the read-out protection was previously activated, the following box should also be checked: unlock protection before a programming cycle 3.2.3 serial number definition the serial numbering window can automatically generate and write serial numbers into the memory of the mcu. automatic serial numbering is defined by specifying: the memory address where it is to be programmed, for example 1000h the length (in bytes), for example 4 the starting value: any value specified by the customer, for example 00000000h ? this is the serial number to be programmed in the mcu the step increment value: any value specified by the customer, for example 1122h serial number settings are shown in figure 2: serial number settings on page 9 .
AN2614 automatic serial number generation in the mcu 9/12 figure 2. serial number settings each time a new chip is programmed, the current ?base value? is programmed at the ?start address? location, over ?length? bytes, and then the ?step? is added to the ?base value?, forming the new ?base value? for the next programming cycle. a unique serial number is therefore assigned to each newly programmed mcu. note: the current serial number value is saved each time a project is closed. it is loaded again, the next time the project (file) is opened. 3.2.4 option byte configuration the option byte configuration window selects the .s19 file corresponding to the mcu option byte definition. this file is created in the ?option byte? tag of the main window by selecting the desired option byte configuration for st7 microcontrollers with flash memory and read-out protection. the file is then saved under a distinct name (different from the main project .s19 file). this .s19 file is automatically loaded each time the project is opened. 3.2.5 program memo ry configuration the program memory configuration window selects the .s19 file corresponding to the mcu software binary file, as created by the c-complier or assembly toolchain. this file does not contain any information regarding the option byte (refer to section 3.2.4 ). this .s19 file is automatically loaded each time the project is opened.
automatic serial number generation in the mcu AN2614 10/12 3.3 automatic programming once the project is fully configured, the progra mming can be started by clicking on ?all tabs? in the ?program? menu or on the icon in figure 3 below. figure 3. starting the program the list of actions enabled in the ?properties? window is then executed by stvp7, including the serial numbering. after each programming sequence, the serial number is updated according to the ?serial numbering? window settings. if the ?prompt for new programming cycle ? box was checked under the ?properties? window, a dialog box automatically appears to start the next programming cycle.
AN2614 revision history 11/12 4 revision history table 3. document revision history date revision changes 23-aug-2007 1 initial release
AN2614 12/12 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2007 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2614

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X